package com.kuang.lesson02;

import utils.JdbcUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TestInsert {
    public static void main(String[] args) {
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;

        try {
//            获取连接
            conn = JdbcUtils.getConnection();
//            获取SQL的执行对象
            st = conn.createStatement();
            String sql ="insert into users(id,name,password,email,birthday)" +
                    " values (4,'狂神','123456','123456@qq.com','2022-01-01')";
//            values()中的值要带单引号，
            int i = st.executeUpdate(sql);
            if(i>0){
                System.out.println("插入成功");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.release(conn,st,rs);
        }
    }
}
